<?php

/*************************************************************************

	FILE INCLUDE

**************************************************************************/
include_once '../lib/Template.class.php';
$debug_mode_value = 0;
checkLogin();

sajax_init();
$sajax_debug_mode = 0;
sajax_export("delDomain");
sajax_handle_client_request();

/*************************************************************************

	USER SCRIPT

***************************************************************************/
$userscript =<<<js
    <script type="text/javascript">
        <!--
		function delDomain(domain_cd){
			if(confirm("Are you sure you want to delete it?")){
				x_delDomain( domain_cd, reloadPage );
			}
		}
		function reloadPage(){
			location.reload();
		}
        //-->
    </script>
js;


/*************************************************************************

		PAGE MAIN PROCESS

***************************************************************************/
(!empty($_REQUEST['page']))? $page = $_REQUEST['page'] : $page = 1;

$db->conn();

$sql = "select count(*)as cnt from domain_tb ";
$c_re=$db->fetch($sql);
$totalrow = $c_re["cnt"];

if(!empty($totalrow)){
	$arr['total']= $totalrow;
	$arr['page'] = $page;
	$arr['row']=20;
	$arr['scale']=10;
	$arr['link']=$link_add;
	$paging= $db->paging($arr);

	$sql = "select *
			from domain_tb
			order by REGISTER_DT desc
			limit ".$paging["limit"]." offset ".$paging["offset"]." ";
	$list = $db->select($sql);

}

$db->close();

$db->conn();
$select_opt = $db->get_selectbox();
$db->close();

/*************************************************************************

	TEMPLATE PROCESS

***************************************************************************/
$body = "SynonymGenerator.html";

$tpl = new Template();
$tpl->setDefine($body);

$tpl->assign("list", $list);
$tpl->assign("paging", $paging);
$tpl->assign("select_opt",$select_opt);

$tpl->setPrint();





/*************************************************************************

	AJAX FUNCTION : Template_ function

***************************************************************************/

function delDomain($domain_cd){
	global $db;

	$db->conn();
	$db->query("delete from candidate_tb
				where CLUSTER_CD in(select CLUSTER_CD from cluster_tb where domain_cd=$domain_cd);");
	$db->query("delete from cluster_tb where domain_cd=$domain_cd;");
	$db->query("delete from domain_tb where domain_cd=$domain_cd;");
	$db->close();
}
















?>
